//
//  SCHeaderViewController.m
//  OurMoon
//
//  Created by dllo on 15/11/3.
//  Copyright © 2015年 sc. All rights reserved.
//

#import "SCHeaderViewController.h"
#import "SCAudioVisualTableView.h"
#import "HTTPMethod.h"
#import "VideoListModel.h"
#import "SCVideoPlayViewController.h"

@interface SCHeaderViewController ()<VideoPlayViewControllerDelegate>
@property(nonatomic, strong)SCAudioVisualTableView *videoTableView;
@property(nonatomic, strong)NSMutableArray *dataSourceArray;
@end

@implementation SCHeaderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = _videoSidListModel.title;
}
- (void)loadView
{
    [super loadView];
    [self getData];
    _videoTableView = [[SCAudioVisualTableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 554) WithType:SCTableViewByVideo];
    _videoTableView.delegate = self;
    [self.view addSubview:_videoTableView];
}

- (void)getData
{
    _dataSourceArray = [NSMutableArray array];
    NSString *urlString = [NSString stringWithFormat:@"http://c.m.163.com/nc/video/list/%@/n/0-10.html", _videoSidListModel.sid];
    [HTTPMethod getDataByString:urlString BodyDic:nil WithDataBlock:^(id data) {
        for (NSDictionary *dic in [data objectForKey:_videoSidListModel.sid]) {
            VideoListModel *videoListModel = [[VideoListModel alloc] init];
            [videoListModel setValuesForKeysWithDictionary:dic];
            [_dataSourceArray addObject:videoListModel];
        }
        _videoTableView.dataVideoListArray = _dataSourceArray;
    }];
}
#pragma mark - 视频跳转视频播放页面的代理方法
- (void)VideoPlayViewControllerJump:(VideoListModel *)videoListModel
{
    SCVideoPlayViewController *vpvc = [[SCVideoPlayViewController alloc] init];
    vpvc.videoListModel = videoListModel;
    [self.navigationController pushViewController:vpvc animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
